<!--
- Author:  L
- Date:    2018/7/24
- File:    index.vue.
-->
<template>
  <div class="seed_container seed_container_box">
    <!--头部-->
    <div class="seed_top_box">
      <div class="seed_top_list" @click="ScanQrcode()">
        <img src="../assets/images/smsh.png" alt="扫码核销">
        <p>扫码核销</p>
      </div>
      <div class="seed_top_listsx">
        <img src="../assets/images/sx.png">
      </div>
      <div class="seed_top_list">
        <div @click="publish_goods()">
          <img src="../assets/images/good_add.png" alt="发布">
          <p>发布商品</p>
        </div>
      </div>
      <div class="seed_top_listsx">
        <img src="../assets/images/sx.png">
      </div>
      <div class="seed_top_list">
        <div @click="publish_notice()">
          <img src="../assets/images/notice_add.png" alt="发布">
          <p>发布公告</p>
        </div>
      </div>
    </div>
    <div class="seed_heng"></div>
    <!--列表-->
    <div class="seed_footer_box">
      <div class="seed_footer_p">
        <router-link :to="{name:'verification-list'}">
          <div class="seed_footer_list">
            <img src="../assets/images/cxgl.png" alt="核销管理">
            <p>核销管理</p>
          </div>
        </router-link>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'order-list'}">
            <div class="seed_footer_list">
              <img src="../assets/images/dagl.png" alt="订单管理">
              <p>订单管理</p>
            </div>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'good-list'}">
            <img src="../assets/images/fbgl.png" alt="商品管理">
            <p>商品管理</p>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'notice-notice'}">
            <img src="../assets/images/tbdh.png" alt="公告管理">
            <p>公告管理</p>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'user-list'}">
            <img src="../assets/images/yxkh.png" alt="用户列表">
            <p>用户列表</p>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'activity-bargain'}">
            <img src="../assets/images/kjgl.png" alt="砍价管理">
            <p>砍价管理</p>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'activity-group'}">
            <img src="../assets/images/ptgl.png" alt="拼团管理">
            <p>拼团管理</p>
          </router-link>
        </div>
      </div>
      <div class="seed_footer_p">
        <div class="seed_footer_list">
          <router-link :to="{name:'activity-seckill'}">
            <img src="../assets/images/msgl.png" alt="秒杀管理">
            <p>秒杀管理</p>
          </router-link>
        </div>
      </div>
    </div>
    <!--尾部-->
    <footer-tab></footer-tab>
    <!--<mt-popup v-model="popupVisible" position="top" :modal=true style="margin-top: 20rem; width: 80%; background-color: rgba(0,0,0,0)">-->
      <!--<div class="seed_publish">-->
        <!--<router-link :to="{name:'notice-add'}">-->
          <!--<button class="seed_publish_btn">发布公告</button>-->
        <!--</router-link>-->
        <!--<router-link :to="{name:'good-operate'}">-->
          <!--<button class="seed_publish_btn">发布商品</button>-->
        <!--</router-link>-->
      <!--</div>-->
    <!--</mt-popup>-->
  </div>
</template>

<script>
import wx from 'weixin-js-sdk'
import $ from 'jquery'
export default {
  data () {
    return {
      bannerList: [],
      balconyList: [],
      noticeList: [],
      panicBuyingList: [],
      newGoodsList: [],
      homeVideo: [],
      hotGoods: {requested: false, loading: false, allLoaded: false, page: 1, pageSize: 10, data: []},
      searchKeyword: '',
      popupVisible: false
    }
  },
  components: {},
  created () {},
  methods: {
    ScanQrcode () {
      let that = this
      $.ajax({
        type: 'post',
        url: 'https://api.zhongzivt.com/mobile/shop.tool.api/return_wx_jssdk', // 自己填写请求地址
        xhrFields: {withCredentials: true},
        data: {'token': this.$utils.getCookie('token')},
        success: function (result) {
          let param = result.data
          wx.config({
            // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            debug: false,
            // 必填，公众号的唯一标识
            appId: param.appId,
            // 必填，生成签名的时间戳
            timestamp: '' + param.timestamp,
            // 必填，生成签名的随机串
            nonceStr: param.nonceStr,
            // 必填，签名，见附录1
            signature: param.signature,
            // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            jsApiList: ['checkJsApi', 'scanQRCode']
          })
        }
      })

      wx.error(function (res) {
        alert('出错了：' + res.errMsg)// 这个地方的好处就是wx.config配置错误，会弹出窗口哪里错误，然后根据微信文档查询即可。
      })

      wx.ready(function () {
        wx.checkJsApi({
          jsApiList: ['scanQRCode'],
          success: function (res) {
          }
        })
        wx.scanQRCode({
          needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
          scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码，默认二者都有
          success: function (res) {
            let result = res.resultStr // 当needResult 为 1 时，扫码返回的结果
            $.ajax({
              type: 'post',
              url: result, // 自己填写请求地址
              xhrFields: {withCredentials: true},
              data: {'token': that.$utils.getCookie('token')},
              success: function (res) {
                if (res.status === 200) {
                  that.$toast('核销成功')
                  that.$router.push({name: 'order-detail', params: {id: res.data, status: 1, c_tab: 1}})
                } else {
                  that.$toast(res.msg)
                }
              },
              error: function (e) {
                that.$toast('核销失败，请稍后重试')
              }
            })
          }
        })
      })
    },
    publish_notice: function () {
      this.$router.push({name: 'notice-add'})
    },
    publish_goods: function () {
      this.$router.push({name: 'good-operate'})
    }
  }
}
</script>

<style>
</style>
